{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "import torchvision\n",
    "import torchvision.transforms as transforms\n",
    "import matplotlib.pyplot as plt\n",
    "import time\n",
    "import d2lzh_pytorch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "#获取训练集\n",
    "mnist_train = torchvision.datasets.FashionMNIST(root='./data',train=True,download = False,transform =transforms.ToTensor())\n",
    "#获取测试集\n",
    "mnist_test = torchvision.datasets.FashionMNIST(root='./data',train=False,download = False,transform = transforms.ToTensor())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "9.45 sec\n"
    }
   ],
   "source": [
    "batch_size=256\n",
    "if sys.platform.startswith('win'):\n",
    "    num_workers=0\n",
    "else:\n",
    "    num_workers=4\n",
    "train_iter=torch.utils.data.DataLoader(mnist_train,batch_size=batch_size,shuffle=True)\n",
    "test_iter=torch.utils.data.DataLoader(mnist_test,batch_size=batch_size,shuffle=True)\n",
    "start=time.time()\n",
    "for x,y in train_iter:\n",
    "    continue\n",
    "print('%.2f sec' % (time.time()-start))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "import torchvision\n",
    "import numpy as np\n",
    "import sys\n",
    "import d2lzh_pytorch as d21"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "batch_size=256\n",
    "train_iter,test_iter=d21.load_data_fashion_mnist(batch_size)\n",
    "num_inputs=784\n",
    "num_outputs=10\n",
    "w=torch.tensor(np.random.normal(0,0.01,(num_inputs,num_outputs)),dtype=torch.float)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python37464bitbasecondab04fb1e447c742be8678bc28fb07e8e2",
   "display_name": "Python 3.7.4 64-bit ('base': conda)"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}